package TOP101;

/**
 * @Question BM29
 * @Date 2022/11/11 11:27
 * @Solution
 */
public class BM29 {
    public boolean hasPathSum (TreeNode root, int sum) {
        if(root==null) {
            return false;
        }
        if(root.left==null && root.right==null && root.val==sum) {
            return true;
        }
        return hasPathSum(root.left,sum-root.val)||hasPathSum(root.right,sum-root.val);
    }
}
